#ifndef CRATE_H
#define CRATE_H

#include "d3dUtil.h"
#include "Light.h"

class Crate
{
public:
	struct Vertex
	{
		Vertex(){}
		Vertex(float x,  float y,  float z,
			float nx, float ny, float nz,
			float u,  float v)
			: pos(x,y,z), normal(nx,ny,nz), texC(u,v){}

		D3DXVECTOR3 pos;
		D3DXVECTOR3 normal;
		D3DXVECTOR2 texC;
	};

public:
	Crate(D3DXVECTOR3* eyePos,D3DXMATRIX* matView,D3DXMATRIX* proj);
	~Crate(void);

	void Init(ID3D10Device* device, float scale);
	void Draw();

private:
	void buildFX();
	void buildVertexLayouts();

private:
	DWORD						m_iNumVertices;
	DWORD						m_iNumIndices;
	DWORD						m_iNumFaces;

	ID3D10Device*				m_pDevice;
	ID3D10Buffer*				m_pVB;
	ID3D10Buffer*				m_pIB;
	ID3D10ShaderResourceView*	m_pDiffuseMapRV;
	ID3D10ShaderResourceView*	m_pSpecMapRV;

	Light						m_ParallelLight;

	ID3D10Effect*				m_pFx;
	ID3D10InputLayout*			m_pInputLayout;
	ID3D10EffectTechnique*		m_pFxTech;

	//FX variable
	ID3D10EffectShaderResourceVariable*	m_pFxDiffuseMapVar;
	ID3D10EffectShaderResourceVariable* m_pFxSpecMapVar;

	ID3D10EffectMatrixVariable*	m_pFxWVPVar;
	ID3D10EffectMatrixVariable*	m_pFxWorldVar;
	ID3D10EffectMatrixVariable* m_pFxTexMtxVar;

	ID3D10EffectVariable*		m_pFxEyePosVar;
	ID3D10EffectVariable*		m_pFxLightVar;

	//Crate Variable
	D3DXMATRIX					m_matWorld;
	D3DXMATRIX*					m_pMatView;
	D3DXMATRIX*					m_pMatProj;
	D3DXMATRIX					m_matWVP;
	D3DXMATRIX					m_matTexMtx;

	D3DXVECTOR3*				m_pEyePos;
};

#endif